//
//  FControl.h
//  test
//
//  Created by 袁飞 on 12-7-12.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "cocos2d.h"

typedef enum{
  TOUCH_DOWN    = 1,
  TOUCH_IN      = 2,
  TOUCH_SLIDE   = 4,
  TOUCH_UP      = 8,
}ControllerState;

@interface FControl : CCLayerColor{
  double            time_begin_;
  CGPoint           point_begin_;
  bool              touch_in_;
  ControllerState   state_;
  NSString          *name_;
}
@property (nonatomic, readwrite) NSString* name;

-(id)init;
-(void)registerWithTouchDispatcher;
-(void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event;
-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event;
-(void)ccTouchMoved:(UITouch *)touch withEvent:(UIEvent *)event;


//implemented by subclass
-(void)onTouchDown:(CGPoint)point;
-(void)onTouchUp:(CGPoint)point;
-(void)onTouchCancel:(CGPoint)point;
-(void)onClick:(CGPoint)point;
-(void)onSlideBegin:(CGPoint)begin End:(CGPoint)end Time:(double)t;

//implemented by subclass to tell controller name and controller size
-(CGRect)getControlRect;
-(NSString*)getName;

-(CGSize)getControlSize;

-(CGPoint)touchLocation:(UITouch *)touch;
-(bool)isContainPoint:(CGPoint)p;

-(void)drawAnchorPoint;
@end
